/*
 * base Javascript
 */

function blockWindow(){
	$.blockUI({ message:null,fadeIn:0,overlayCSS: { backgroundColor: '#CCC',cursor:"default" }});
}
function blockWindowContent(content){
	$.blockUI({ message:content,fadeIn:0,overlayCSS: { backgroundColor: '#CCC',cursor:"default" }});
}
function unblockWindow(){
	$.unblockUI();
}

artDialog.confirm = function (content, yes, no) {
	return artDialog({
		id: 'Confirm',
		icon: 'question',
		opacity: .1,
		content: content,
		drag: false,
		resize: false,
		ok: function (here) {
			return yes.call(this, here);
		},
		cancel: function (here) {
			return no && no.call(this, here);
		}
	});
};

artDialog.errorAlert = function (content, yes, no) {
	return artDialog({
		id: 'Confirm',
		icon: 'error',
		opacity: .1,
		content: content,
		drag: false,
		ok: function (here) {
			return yes.call(this, here);
		},
		cancel: function (here) {
			return no && no.call(this, here);
		}
	});
};


function quit(){
	blockWindow();
	art.dialog.confirm("确定退出系统?", function(){
		unblockWindow();
		location.href='logout.do';
	},function(){
		unblockWindow();
	});
}

artDialog.tipsBlue = function (content, time) {
    return artDialog({
        id: 'Tips',
        title: false,
        cancel: false
    })
    .content('<div style="padding: 0 1em;font-size:12px;color:1C7887">' + content + '</div>')
    .time(time || 1.5);
};

artDialog.tipsRed = function (content, time) {
    return artDialog({
        id: 'Tips',
        title: false,
        cancel: false
    })
    .content('<div style="padding: 0 1em;font-size:12px;color:red">' + content + '</div>')
    .time(time || 1.5);
};

//检测日期合法
function IsDate( psValue )
{
    if(psValue != "")
    {
        psValue = psValue.replace("-", "/");
        psValue = psValue.replace("-", "/");
        psValue = psValue.replace(".", "/");
        psValue = psValue.replace(".", "/");
        psValue = psValue.replace("/0", "/");
        psValue = psValue.replace("/0", "/");
       
        var psValueArray = psValue.split("/");
        if (psValueArray[0].length !=4)
        {
            return false
        }
                   
        var oDate = new Date(psValue);
       
        var strYear = new String(oDate.getFullYear());
        var strMonth = new String(oDate.getMonth() + 1);
        var strDay = new String(oDate.getDate());
        var strTestDate = strYear + "/" + strMonth + "/" + strDay;
        return psValue == strTestDate;
    }
    else
    {
        return true;
    }
}
